package com.fit.entities.user;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.tapestry5.beaneditor.NonVisual;
import org.hibernate.annotations.NaturalId;


import com.fit.model.UserRole;

@Entity
@Table(name="user")
public class User {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	
	@Column(name = "user_id")
	private Long id;
	@NaturalId
	@Column(nullable = false, unique = true, name = "username")
	private String userName;
	
	
	@Column(name="email", nullable = false)
	private String email;
	
	@Column(name="password", nullable = false)
	
	private String password;
	
	@Column(nullable = false, name = "role")
	private UserRole role;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public UserRole getRole() {
		return role;
	}

	public void setRole(UserRole role) {
		this.role = role;
	}

	
	public boolean isAdmin() {
		if (role == UserRole.ADMIN) {
			return true;
		}
		return false;
	}

	public boolean isMember() {
		if (role == UserRole.MEMBER) {
			return true;
		}
		return false;
	}
	
	public boolean isCoach() {
		if (role == UserRole.COACH) {
			return true;
		}
		return false;
	}

	
	
}
